<template>
	<!-- 底部导航栏 -->
	<view class="tabbar">
		<van-tabbar v-model="active" @change="go">
			<van-tabbar-item icon="home-o">首页</van-tabbar-item>
			<van-tabbar-item icon="search">分类</van-tabbar-item>
			<van-tabbar-item icon="friends-o">购物车</van-tabbar-item>
			<van-tabbar-item icon="setting-o">个人中心</van-tabbar-item>
		</van-tabbar>
	</view>
</template>

<script>
	import {
		ref
	} from 'vue';
	
	export default {
		setup() {
			const active = ref(0);
			const go = (e) =>{
				console.log(e);
				let router = ['index', 'cate', 'cart', 'user']
				uni.reLaunch({
					url: `/pages/${router[e]}/index`
				})
			}
			return {
				active,
				go
			};
		},
		props:{
			index:{
				type:Number,
				default:0,
				require:true,
			}
		},
		created() {
			this.active = this.index
		}
	};
</script>

<style>
</style>